<template>
	<view class="content">
		<view class="content_head">
			<image class="logo" src="../../static/ailogo.png" mode=""></image>
		</view>
		<view class="application_title">
			<view class="title">
				AI应用
			</view>
			<view class="subtitle">
				AIAPPLICATION
			</view>
			<view class="FX1"></view>
			<view class="all" @click="appAll">
				更多
				<image src="../../static/syto.png" mode=""></image>
			</view>
		</view>
		<view class="applicationList">
			<view :class="['applicationBox',index==activeBox ? 'activeBox' : '']"
				v-for="(item,index) in applicationList" :key="index" @click="activeAPP(item,index)">
				<image class="logo" :src="!item.filePath || item.filePath == ''?'../../static/yytx.png':item.filePath" mode=""></image>
				<view class="title">
					{{item.aiuseTitle}}
				</view>
				<view class="label">
					{{item.aiuseContent}}
				</view>
				<view class="look" @click="gotoPage('/pages/aiuse/writing/index?aiuseId='+item.aiuseId)">
					去查看
				</view>
			</view>
		</view>
		<view class="application_title">
			<view class="title">
				AI课程
			</view>
			<view class="subtitle">
				COURSE
			</view>
			<view class="FX1"></view>
			<view class="all" @click="couresAll">
				更多
				<image src="../../static/syto.png" mode=""></image>
			</view>
		</view>
		<view class="courseList">
			<view class="courseBox" v-for="(item,index) in productList"
				@click="gotoPage('/pages/product/detail/detail?productId='+item.productId)">
				<image class="logo" :src="item.productImage" mode=""></image>
				<view class="title">
					<text>{{item.productName}}</text>
					<view class="FX1"></view>
					<image class="like" src="../../static/yyz.png" mode=""></image>
				</view>
				<view class="novice">
					新手必备
				</view>
				<view class="coursebottom">
					<view class="box" style="margin-right: 66rpx;">
						<image src="../../static/yyy.png" mode=""></image>
						<text>{{item.viewTimes}}</text>
					</view>
					<view class="box">
						<image src="../../static/yyx.png" mode=""></image>
						<text>{{item.productSales}}</text>
					</view>
					<view class="FX1"></view>
					<view class="price">
						¥{{item.marketPrice}}
					</view>
				</view>
			</view>
		</view>
		<up-popup mode="center" custom-style="background: none" :show="show">
			<view class="showCount">
				<view class="bg">
					<view class="tex">
						<text>成为</text>
						<text class="vip">VIP</text>
					</view>

				</view>
				<view class="count">
					<view class="title">
						<text class="tex1">尽需</text>
						<text class="tex2">299</text>
						<text class="tex3">元</text>
					</view>
					<view class="tips">
						申请成为AI会员开启使用
					</view>
					<view class="btn">
						立即开通
					</view>
				</view>
				<image @click="onClose" class="close" src="../../static/tc1.png" mode=""></image>
			</view>
		</up-popup>

	</view>
	<tabBar></tabBar>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				disabled: true,
				activeBox: 0,
				applicationList: [],
				productList: [],
				page: 1,
				last_page: 0,
				no_more: false,
			}
		},
		onLoad() {
			//获取热门的AI应用
			this.getHotApplication();
			this.getHotProduct();
		},
		methods: {
			appAll() {
				uni.navigateTo({
					url: '/pages/aiuse/index'
				});
			},
			couresAll() {
				uni.navigateTo({
					url: '/pages/college/index'
				});
			},
			activeAPP(e, index) {
				// this.show = true
				this.activeBox = index
			},
			onClose() {
				this.show = false
			},
			/*获取数据*/
			getHotApplication() {
				let self = this;
				let page = self.page;
				self.loading = true;
				self._get('plus/aiuse/aiuse/index', {
					pageIndex: page || 1,
					isHot: 1,
					sortPrice: 0,
					pageSize: 10,
				}, function(res) {
					self.loading = false;
					self.applicationList = res.data.records;
				});
			},
			/*获取数据*/
			getHotProduct() {
				let self = this;
				let page = self.page;
				self.loading = true;
				self._postBody('product/product/lists', {
					pageIndex: page || 1,
					categoryId: self.categoryId,
					search: '',
					sortType: 'all',
					sortPrice: 0,
					pageSize: 10,
				}, function(res) {
					self.loading = false;
					uni.stopPullDownRefresh();
					self.productList = self.productList.concat(res.data.records);
					self.last_page = res.data.lastPage;
					if (res.data.lastPage <= 1) {
						self.no_more = true;
					}
				});
			},
		}
	}
</script>
<style>
	page {
		background-color: white;
	}
</style>
<style lang='css' scoped>
	.content_head {
		width: 750rpx;
		height: 595rpx;
		background-image: url('../../static/sybg.jpg');
		background-size: 100% 100%;

		.logo {
			width: 240rpx;
			height: 64rpx;
			padding-top: 95rpx;
			margin-left: 30rpx;
		}
	}

	.application_title {
		display: flex;
		align-items: center;
		margin-top: 60rpx;
		margin-bottom: 28rpx;
		margin-left: 37rpx;
		margin-right: 20rpx;

		.title {
			font-weight: bold;
			font-size: 36rpx;
			color: #333333;
			margin-right: 13rpx;
		}

		.subtitle {
			font-weight: bold;
			font-size: 30rpx;
			color: #CCCCCC;
		}

		.all {
			display: flex;
			align-items: center;
			font-weight: 400;
			font-size: 24rpx;
			color: #999999;

			image {
				width: 30rpx;
				height: 30rpx;
				margin-left: 10rpx;
			}
		}

	}

	.applicationList {
		margin: 0 25rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;
		gap: 20rpx;
		/* margin-bottom: 47rpx; */

		.applicationBox {
			text-align: center;
			display: flex;
			align-items: center;
			flex-direction: column;
			width: 220rpx;
			background: #F6F6F6;
			border-radius: 20rpx;

			.logo {
				width: 110rpx;
				height: 110rpx;
				margin-top: 25rpx;
			}

			.title {
				font-weight: 400;
				font-size: 32rpx;
				color: #333333;
				margin-top: 15rpx;
			}

			.label {
				font-size: 24rpx;
				color: #999999;
			}

			.look {
				text-align: center;
				width: 120rpx;
				height: 50rpx;
				line-height: 50rpx;
				background: #D3D3D3;
				font-weight: 400;
				font-size: 24rpx;
				color: #FFFFFF;
				border-radius: 15rpx;
				margin: 0 auto;
				margin-top: 35rpx;
				margin-bottom: 33rpx;
			}
		}

		.activeBox {
			background-image: url('../../static/yybj2.png');
			background-size: 100% 100%;

			.title {
				color: #FFFFFF;
			}

			.label {
				color: #FFFFFF;
			}

			.look {
				background: #FFFFFF;
				color: #0F4BCB;
			}
		}
	
	}

	.courseList {
		padding-bottom: 70rpx;

		.courseBox {
			width: 710rpx;
			height: 190rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 2rpx 22rpx 5rpx rgba(7, 67, 200, 0.1);
			border-radius: 20rpx;
			margin: 96rpx 20rpx 0 20rpx;
			position: relative;

			.logo {
				width: 210rpx;
				height: 250rpx;
				border-radius: 30rpx 30rpx 0rpx 30rpx;
				position: absolute;
				left: 0;
				bottom: 0;
			}

			.title {
				margin-left: 240rpx;
				display: flex;
				font-weight: 400;
				font-size: 32rpx;
				color: #000000;
				padding-top: 20rpx;

				text {
					display: inline-block;
					width: 400rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				.like {
					width: 40rpx;
					height: 40rpx;
					margin-right: 20rpx;
				}
			}

			.novice {
				margin-left: 240rpx;
				margin-top: 15rpx;
				width: 130rpx;
				height: 40rpx;
				line-height: 40rpx;
				background: rgba(235, 241, 255, 0);
				border-radius: 10rpx;
				border: 1px solid #0F4BCB;
				font-weight: 400;
				font-size: 24rpx;
				color: #0F4BCB;
				text-align: center;
			}

			.coursebottom {
				margin-top: 26rpx;
				margin-left: 240rpx;
				display: flex;
				align-items: center;
				font-size: 24rpx;
				color: #999999;

				.box {
					display: flex;
					align-items: center;
				}

				image {
					width: 30rpx;
					height: 30rpx;
					margin-right: 6rpx;
				}

				.price {
					color: #0F4BCB;
					margin-right: 30rpx;
				}
			}
		}

	}

	.showCount {
		text-align: center;

		.bg {
			width: 580rpx;
			height: 380rpx;
			background-image: url('../../static/tc.png');
			background-size: 100% 100%;
			margin: 0 auto;
			position: relative;

			.tex {
				position: absolute;
				bottom: 24rpx;
				left: 57rpx;
				font-size: 24rpx;
				color: #FFFFFF;

				.vip {
					font-style: italic;
					font-size: 48rpx;
				}
			}
		}

		.count {
			width: 650rpx;
			height: 350rpx;
			background: linear-gradient(40deg, #D4E2FF, #FFFFFF, #E2EFFF);
			border-radius: 30rpx;

			.title {
				display: flex;
				align-items: flex-end;
				justify-content: center;
				padding-top: 62rpx;

				.tex1 {
					writing-mode: vertical-rl;
					font-weight: 300;
					font-size: 24rpx;
					color: #2168EA;
				}

				.tex2 {
					font-weight: bold;
					font-size: 85rpx;
					color: #2168EA;
					line-height: 62rpx;

				}

				.tex3 {
					font-weight: 300;
					font-size: 23rpx;
					color: #FFFFFF;
					width: 36rpx;
					height: 36rpx;
					line-height: 36rpx;
					background-color: #2168EA;
					border-radius: 50%;
					display: inline-block;
				}
			}

			.tips {
				font-weight: 300;
				font-size: 30rpx;
				color: #999999;
				padding-top: 27rpx;
			}

			.btn {
				margin: 0 auto;
				width: 280rpx;
				height: 70rpx;
				line-height: 70rpx;
				background: linear-gradient(-90deg, rgba(255, 67, 95, 0.99), rgba(255, 164, 77, 0.99));
				border-radius: 35rpx;
				margin-top: 48rpx;
				font-size: 36rpx;
				color: #FFFFFF;
			}
		}

		.close {
			width: 55rpx;
			height: 55rpx;
			margin-top: 70rpx;
		}
	}
</style>